﻿using System;

namespace ExcelConfig
{
    using ExcelConfig.Config;
    using ExcelConfig.helpers;
    using System.Collections.Generic;

    public class CellObj
    {
        internal object obj { get; set; }
        internal CellObj(object obj) { this.obj = obj; }
        public string Text { get { return helper.parse_to_text(obj); } }
        public decimal Number { get { return helper.parse_to_number(obj); } }
        public bool YesOrNo { get { return Text == ExcelConfigSetting.YES;} }
        public string[] Array(string name)
        {
            var arr = new Queue<string>();
            foreach (var text in LoopArray(name)) arr.Enqueue(text);
            return arr.ToArray();
        }
        public IEnumerable<string> LoopArray(string name)
        {
            var arr = Text.Split(ExcelConfigSetting.ArraySplitChar);
            for (var i = 0; i < arr.Length; i++) if (!string.IsNullOrEmpty(arr[i])) yield return arr[i];
        }
    }
}
